package asia.doing.service.manage;


import asia.doing.entity.Tool;
import asia.doing.entity.User;
import asia.doing.mapper.ToolMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service(value = "manageToolService")
public class ToolService {
    @Resource
    private ToolMapper toolMapper;

    public List<Tool> selectTool(Tool tool){
        return toolMapper.selectAll(tool);
    }

    public void addTool(Tool tool){
        toolMapper.insert(tool);
    }

    public void updateTool(Tool tool){
        toolMapper.updateById(tool);
    }

    public void deleteTool(Integer id){
        toolMapper.deleteById(id);
    }

    public PageInfo<Tool> selectPage(Tool tool,int pageNum,int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        //注意:这里获取到的信息是重复的
        List<Tool> list = toolMapper.selectAll(tool);
        System.out.println(list.size());
        PageInfo<Tool> pageInfo = PageInfo.of(list);
//      List<Activity> activityList = pageInfo.getList(); 可以获取所有列表循环做其他事情
        return pageInfo;
    }
}
